window.AvailabilityDetailQuery = (function($, module) {	
	/**
	 * 初始化函数
	 */
	function init(){
		initPage(1);
	}
	
	//默认加载  
    function initPage(pageNo){
    	var paramData = CommonUtils.serializeToJSON($(".select_text input").serializeArray());
    	$.ajax({
            url:"stockRecordQuery/queryStockRecord/"+pageNo+"/10",
            type:"post",
            data:JSON.stringify(paramData),
            contentType:"application/json;charset=utf-8",
            success:function(data){
            	showBills(data);
        		$(".pager").Page({
        			totalPages: data.totalPage||0,//分页总数
        			liNums: 7,//分页的数字按钮数(建议取奇数)
        			activeClass: 'activP', //active 类样式定义
        			callBack : function(pageNo){
        				PageClick(pageNo);
        			}
        		}); 

            },
            error:function(data){
                alert("error");
            }
        });
    }
    
    //回调函数  
    function PageClick(pageNo) {  
        initPage(pageNo); 
    }
	
    $(".search").click(function(){
    	initPage(1);
    });
	//列表展示
	function showBills(data){
		$("#tablelist").html("");
    	var datas = data['stockRecordList'];
    	if(datas){
    		$.each(datas,function(item,obj){
    			var dom = "";
    			dom += "<tr class='listTableText list_list'>";
    			dom += "<td>"+CommonUtils.formatStr(obj.stage)+"</td>";
    			dom += "<td>"+CommonUtils.formatStr(obj.graphNumber)+"</td>";
    			dom += "<td>"+CommonUtils.formatStr(obj.materialName)+"</td>";
    			dom += "<td>"+CommonUtils.formatStr(obj.materialCode)+"</td>";
    			dom += "<td>"+CommonUtils.formatStr(obj.batchNo)+"</td>";
    			dom += "<td>"+CommonUtils.formatStr(obj.nums)+"</td>";
    			dom += "<td>"+CommonUtils.formatTime(obj.storeName)+"</td>";
    			dom += "<td>"+CommonUtils.formatTime(obj.instockTime)+"</td>";			
    			dom += "</tr>";			
    			$("#tablelist").append(dom);
    		});
    		$("tbody tr:odd").css("background","#EBF5FF");  	
    	}
    }
	
	module.init = init;
	return module;
}($, window.AvailabilityDetailQuery || {}));
$(function() {
	AvailabilityDetailQuery.init();
});